package com.zondy.mapgis.psmap.manager.constant;

import java.util.Arrays;
import java.util.Objects;

public enum CloudProtocolType {
   UNKNOWN(0, "未知", (String)null),
   IGSRestMap(1, "地图服务", "MapServer"),
   IGSRestTile(2, "栅格瓦片服务", "TileServer"),
   IGSRestFeature(3, "要素服务", "FeatureServer"),
   IGSRestVectorTile(4, "矢量瓦片服务", "VectorTileServer"),
   IGSRestScene(5, "三维场景服务", "SceneServer"),
   IGSRestM3D(6, "M3D服务", "M3dServer"),
   IGSRestImage(7, "影像服务", "ImageServer"),
   IGSRestTerrain(8, "地形服务", "TerrainServer"),
   IGSRestWorkflow(10, "工作流服务", "WorkflowServer"),
   IGSRestGeometry(11, "地理几何服务", "GeometryServer"),
   IGSRestResource(12, "资源服务", "ResourceServer"),
   IGSRestPlot(13, "标绘服务", "PlotServer"),
   IGSExtension(16, "扩展服务", "ExtensionServer"),
   WMS(17, "OGC WMS", "WMSServer"),
   WFS(18, "OGC WFS", "WFSServer"),
   WMTS(19, "OGC WMTS", "WMTSServer"),
   WCS(20, "OGC WCS", "WCSServer"),
   WPS(21, "OGC WPS", "WPSServer"),
   CSW(22, "OGC CSW", "CSWServer"),
   ArcGISRestMapServer(33, "ArcGIS Rest地图服务", "arcgis/MapServer"),
   ArcGISRestFeatureServer(34, "ArcGIS Rest要素服务", "arcgis/FeatureServer"),
   ArcGISRestVectorTileServer(35, "ArcGIS Rest矢量瓦片服务", "arcgis/VectorTileServer"),
   ArcGISRestGeometryServer(36, "ArcGIS Rest几何服务", "arcgis/GeometryServer"),
   ArcGISRestGPServer(37, "ArcGIS Rest地理处理服务", "arcgis/GpServer"),
   IGSRestAddress(38, "地名地址服务", "AddressServer"),
   IGSRest3DTiles(39, "3DTiles服务", "3DTilesServer"),
   IGSRestPoi(40, "兴趣点服务", "PoiServer"),
   RegistrationServer(101, "注册服务", ""),
   AggMapServer(102, "聚合地图服务", "");

   private final int value;
   private final String name;
   private final String restServerPrefix;

   private CloudProtocolType(int v, String name, String restServerPrefix) {
      this.value = v;
      this.name = name;
      this.restServerPrefix = restServerPrefix;
   }

   public static CloudProtocolType fromString(String name) {
      return (CloudProtocolType)Arrays.stream(values()).filter((t) -> {
         return t.toString().equalsIgnoreCase(name);
      }).findFirst().orElse(UNKNOWN);
   }

   public static CloudProtocolType fromValue(int value) {
      return (CloudProtocolType)Arrays.stream(values()).filter((t) -> {
         return t.value == value;
      }).findFirst().orElse(UNKNOWN);
   }

   public static CloudProtocolType fromStringOrValue(String str) {
      CloudProtocolType type = fromString(str);
      if (type == UNKNOWN) {
         try {
            return fromValue(Integer.parseInt(str));
         } catch (Exception var3) {
         }
      }

      return type;
   }

   public static CloudProtocolType fromServerType(String serverType, boolean isArcgis) {
      if (serverType != null) {
         String serverPrefix = isArcgis ? "arcgis/" + serverType : serverType;
         return (CloudProtocolType)Arrays.stream(values()).filter((t) -> {
            return Objects.equals(t.restServerPrefix, serverPrefix);
         }).findFirst().orElse(UNKNOWN);
      } else {
         return UNKNOWN;
      }
   }

   public int getValue() {
      return this.value;
   }

   public String getName() {
      return this.name;
   }

   public String getRestServerPrefix() {
      return this.restServerPrefix;
   }
}
